<link href="__ADMIN__/css/juncms.min2.css?v=1" rel="stylesheet" type="text/css" />  


<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					从左侧选择权限菜单，然后再提交请求。
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">


								<div class="org-left-col tray-cell j_depa" style="float:left;margin-right: 10px">
									<div class="org-left-header">
										<span class="tab">
											<a id="organization-users" class="router j_user active">
												权限菜单
											</a>
										</span>
									</div>
									<a id="show-first-group" class="hide router">
									</a>
									<div id="org-tree" class="org-tree scrollwrapper mCustomScrollbar _mCS_24 mCS_no_scrollbar" style="height: 100%;">
										<div id="mCSB_24" class="mCustomScrollBox mCS-darkblue mCSB_vertical_horizontal mCSB_inside" >
											<div id="mCSB_24_container_wrapper">
												<div id="mCSB_24_container" class="mCSB_container" style="position: relative; top: 0px; left: 0px; width: 100%;" >
													<div id="org-tree-list" class="mt-15">
															
													</div>
													
												</div>
											</div>
										</div>
									</div>
								</div>

								<div class="fixed-table-container" style="width:-webkit-calc(100% - 310px); width:-moz-calc(100% - 310px); width:calc(100% - 310px);float: left;">
									<div class="fixed-table-body">
										
											<form class="layui-form" >
												<div class="layui-form-item">
													<label class="layui-form-label">角色名称：</label>
													<div class="layui-input-block">
														<input type="text" id="name" placeholder="角色名称" class="layui-input">
													</div>
												</div>
												<div class="layui-form-item">
													<label class="layui-form-label">启用/禁用：</label>
													<div class="layui-input-block">
														<input type="checkbox" name="status" id="status" value="1" lay-skin="switch" lay-text="启用|禁用">
													</div>
												</div>
												<div class="layui-form-item layui-form-text">
													<label class="layui-form-label">备 注：</label>
													<div class="layui-input-block">
														<textarea name="desc" placeholder="可为空" class="layui-textarea" id="remark" rows="4"></textarea>
													</div>
												</div>
											</form>

									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

	
<style>
#demo input[type=checkbox], #demo  input[type=radio], #demo select {display: initial;}
.layui-tree-branch,.layui-tree-leaf{display: none}
input[type="checkbox"], input[type="radio"]{margin-top: 9px}
</style>
<script>
layui.use(['form','tree'], function(){
	var form = layui.form;
	// 权限节点树
	var tree = layui.tree({
				elem: '#org-tree-list',
				check: 'checkbox',
				skin: 'as',
				drag: true,
				checkboxName: 'id',
				checkboxStyle: "",
				nodes: {$json}
		});
});

function doSubimt() {
	var res;
	var id =[]; 
	$('input[name="id"]:checked').each(function(){ 
		id.push($(this).val()); 
	}); 
	var name        = $('#name').val();
	var status      = (document.getElementById("status").checked === true) ? $('#status').attr('value') : 2;
	var remark      = $('#remark').val();
	var data        = {'id':JSON.stringify(id), 'name':name, 'remark':remark, 'status':status};
	if (name == '') {
		$.thinkmimi({Content : '角色名称不能为空！', Type:2, Align:'right', OutTime:2000});return false;
	}
	var font_num= {}; 
	font_num.get_length = function(str) { 
		return str.replace(/[\u0391-\uFFE5]/g, "a").length;
	};
	if (font_num.get_length(name) > 20) {
		$.thinkmimi({Content : '角色名称最大只支持20个汉字！', Type:2, Align:'right', OutTime:2000});return false;
	}

	$.ajax({
		type: 'post',
		data: data,
		async: false,
		url: "{:url('add')}",
		success: function(data) {
			var array = eval('('+data+')');
			res = array;
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				res = false;
			}
		}
	});
	return res;
}
</script>